<?php
namespace UHU\WebComic\Parser\RegEx;
class Numbered extends \UHU\WebComic\Parser\RegEx
{
	const regex = '(\d+)';
	protected function nab()
	{
		$matches = parent::nab();
		foreach($matches as $match)
		{
			$this->RSS[] = new \UHU\WebComic\RSS\Item($this->convert_match_to_title($match),$this->convert_match_to_description($match),sprintf($this->sprintf_link,$match));
		}
	}
	protected function convert_match_to_description($issue)
	{
		return $this->convert_match_to_title($issue);
	}
	protected function convert_match_to_title($issue)
	{
		return 'Issue ' . $issue . ' of ' . $this->title . '.';
	}
}
class prefixNumbered extends Numbered
{
	protected $regex_prefix;
	public function __construct($title,$description,$link,$image,$copyright,$source_url,$sprintf_link,$regex_prefix)
	{
		$this->regex_prefix = $regex_prefix;
		parent::__construct($title,$description,$link,$image,$copyright,$source_url,$sprintf_link);
	}
	protected function the_regex()
	{
		return $this->regex_prefix . parent::the_regex();
	}
}
class YYYYMMDD extends \UHU\WebComic\Parser\RegEx
{
	const regex = '(\d{4}[\-\_\ ]?\d{2}[\-\_\ ]?\d{2})';
	protected function nab()
	{
		$matches = parent::nab();
		foreach($matches as $match)
		{
			$this->RSS[] = new \UHU\WebComic\RSS\Dated_Item($this->convert_match_to_title($match),$this->convert_match_to_description($match),sprintf($this->sprintf_link,$match),$match);
		}
	}
	protected function convert_match_to_description($date)
	{
		return 'Issue of ' . $this->title . ' dated ' . date('F jS, Y',strtotime($date));
	}
	protected function convert_match_to_title($date)
	{
		return date('F jS, Y',strtotime($date));
	}
}
class prefixYYYYMMDD extends YYYYMMDD
{
	protected $regex_prefix;
	public function __construct($title,$description,$link,$image,$copyright,$source_url,$sprintf_link,$regex_prefix)
	{
		$this->regex_prefix = $regex_prefix;
		parent::__construct($title,$description,$link,$image,$copyright,$source_url,$sprintf_link);
	}
	protected function the_regex()
	{
		return $this->regex_prefix . parent::the_regex();
	}	
}
class YYYYMMDD_img extends YYYYMMDD
{
	protected function regex()
	{
		return parent::regex() . '\.(gif|jpe|jpg|jpeg|png)';
	}
}
class YYYYMMDDw_img extends YYYYMMDD_img
{
	protected function the_regex()
	{
		return str_replace('\.(','\w\.(',parent::the_regex());
	}
}
class prefixYYYYMMDDw_img extends YYYYMMDDw_img
{
	protected $regex_prefix;
	public function __construct($title,$description,$link,$image,$copyright,$source_url,$sprintf_link,$regex_prefix)
	{
		$this->regex_prefix = $regex_prefix;
		parent::__construct($title,$description,$link,$image,$copyright,$source_url,$sprintf_link);
	}
	protected function the_regex()
	{
		return $this->regex_prefix . parent::the_regex();
	}
}
?>